package com.ly.blog2Word.controller;

import com.alibaba.fastjson.JSONObject;
import com.ly.blog2Common.core.http.ResponseMessage;
import com.ly.blog2Common.core.page.PageRequest;
import com.ly.blog2Word.dao.model.WordSearch;
import com.ly.blog2Word.service.CommAdminService;
import com.ly.blog2Word.service.WordSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lyMaster
 * @time: 2020/7/17 19:16
 */
@RequestMapping("/search")
@RestController
public class WordSearchController {


    @Autowired
    private WordSearchService wordSearchService;

    @Autowired
    private CommAdminService commAdminService;


    @PostMapping(value="/save")
    public JSONObject save(@RequestBody WordSearch record) {
        return ResponseMessage.ok(wordSearchService.save(record));
    }

    @PostMapping(value="/delete")
    public JSONObject delete(@RequestBody List<WordSearch> records) {
        return ResponseMessage.ok(wordSearchService.delete(records));
    }

    @PostMapping(value="/findPage")
    public JSONObject findPage(@RequestBody PageRequest pageRequest) {
        return ResponseMessage.ok(wordSearchService.findPage(pageRequest));
    }

    @PostMapping(value="/findSearchList")
    public JSONObject findSearchList(@RequestBody JSONObject searchKeyObj) {
            return ResponseMessage.ok(wordSearchService.findSearchList(searchKeyObj.getString("searchKey")));
    }

}
